package com.htl.exampro.base.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.htl.exampro.base.utils.UserUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        String userId = UserUtil.getUserId();
        log.info("开始插入填充... createdPerson:{}", userId);
        this.strictInsertFill(metaObject, "createdPerson", String.class, userId);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        String userId = UserUtil.getUserId();
        log.info("开始更新填充... updatedPerson:{}", userId);
        this.strictUpdateFill(metaObject, "updatedPerson", String.class, userId);
    }
}